/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mlbs.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author mckd87
 */
@Entity
@Table(name = "devicelocation")
@NamedQueries({@NamedQuery(name = "Devicelocation.findByDeviceId", query = "SELECT d FROM Devicelocation d WHERE d.deviceId = :deviceId"), @NamedQuery(name = "Devicelocation.findByStreet", query = "SELECT d FROM Devicelocation d WHERE d.street = :street"), @NamedQuery(name = "Devicelocation.findByCity", query = "SELECT d FROM Devicelocation d WHERE d.city = :city"), @NamedQuery(name = "Devicelocation.findByState", query = "SELECT d FROM Devicelocation d WHERE d.state = :state"), @NamedQuery(name = "Devicelocation.findByLat", query = "SELECT d FROM Devicelocation d WHERE d.lat = :lat"), @NamedQuery(name = "Devicelocation.findByLongitude", query = "SELECT d FROM Devicelocation d WHERE d.longitude = :longitude"), @NamedQuery(name = "Devicelocation.findByLastUpdate", query = "SELECT d FROM Devicelocation d WHERE d.lastUpdate = :lastUpdate")})
public class Devicelocation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "deviceId", nullable = false)
    private String deviceId;
    @Column(name = "street")
    private String street;
    @Column(name = "city")
    private String city;
    @Column(name = "state")
    private String state;
    @Column(name = "lat")
    private Float lat;
    @Column(name = "longitude")
    private Float longitude;
    @Column(name = "last_update", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdate;
    @JoinColumn(name = "deviceId", referencedColumnName = "deviceid", insertable = false, updatable = false)
    @OneToOne
    private Device device;
    @JoinColumn(name = "userid", referencedColumnName = "userId")
    @ManyToOne
    private Usertable userid;

    public Devicelocation() {
    }

    public Devicelocation(String deviceId) {
        this.deviceId = deviceId;
    }

    public Devicelocation(String deviceId, Date lastUpdate) {
        this.deviceId = deviceId;
        this.lastUpdate = lastUpdate;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Float getLat() {
        return lat;
    }

    public void setLat(Float lat) {
        this.lat = lat;
    }

    public Float getLongitude() {
        return longitude;
    }

    public void setLongitude(Float longitude) {
        this.longitude = longitude;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public Device getDevice() {
        return device;
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public Usertable getUserid() {
        return userid;
    }

    public void setUserid(Usertable userid) {
        this.userid = userid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (deviceId != null ? deviceId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Devicelocation)) {
            return false;
        }
        Devicelocation other = (Devicelocation) object;
        if ((this.deviceId == null && other.deviceId != null) || (this.deviceId != null && !this.deviceId.equals(other.deviceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mlbs.entity.Devicelocation[deviceId=" + deviceId + "]";
    }

}
